<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function jump(nums) {
            if(nums.length<=1) return 0
            let max = nums[0]
            let maxIndex = nums[0]
            let step = 1
            for (let i=1; i<nums.length-1; i++) {
                if(max>=i && nums[i]+i>max){
                    max = nums[i]+i
                }
                if(i == maxIndex) {
                    step++
                    maxIndex = max
                }
            }
            return step
        }
        console.log(jump([0]))
    </script>
</body>
</html>